import {
  mapConfigList,
  pubtabcolsList,
  pubtabcolsUpdate,
} from 'api/layerSetting';

export default {
  namespace: 'layerSetting',
  state: {
  },

  effects: {
    *mapConfigList({ payload }, { call, put }) {
      const result = yield call(mapConfigList, payload)
      if (result && result.success) {
        yield put({
          type: 'setState',
          payload: {
            mapConfigList: result.data,
          },
        })
        return result;
      } else {
        throw result
        return result;
      }
    },
    *pubtabcolsList({ payload }, { call, put }) {
      const result = yield call(pubtabcolsList, payload)
      if (result && result.success) {
        return result.data.list
      }
      return null
    },
    *pubtabcolsUpdate({ payload }, { call, put }) {
      const result = yield call(pubtabcolsUpdate, payload)
    },
  },

  reducers: {
    setState(state, action) {
      return {
        ...state,
        ...action.payload,
      };
    },
  },
};
